package com.study.seata.account.controller;

import com.study.seata.account.service.AccountService;
import com.study.seata.common.model.account.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author Mayjean
 * @date 2020/11/11
 */
@Controller
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    /**
     *
     * @param account
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> insert(@RequestBody Account account,HttpServletRequest request) {
        Map<String, Object> result = accountService.insert(account);
        return result;
    }

    /**
     *
     * @param account
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> delete(@RequestBody Account account,HttpServletRequest request) {
        Map<String, Object> result = accountService.delete(account);
        return result;
    }


    /**
     *
     * @param account
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> update(@RequestBody Account account,HttpServletRequest request) {
        Map<String, Object> result = accountService.update(account);
        return result;
    }

}